#pragma once

#include <iostream>
#include <vector>
#include <fstream>
#include <string>

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/calib3d/calib3d.hpp>


class CameraCalibrator
{
public:
    CameraCalibrator();
    ~CameraCalibrator();

    int addChessboardPoints( cv::Size &board_size, cv::Mat imageInput );

    double  calibrate(cv::Size &imageSize);

    cv::Mat remap(cv::Mat &imageInput, cv::Size &image_size);

private:
    std::vector< std::vector<cv::Point3f> >objectPoints;
    std::vector< std::vector<cv::Point2f> >imagePoints;

    cv::Mat  cameraMatrix;
    cv::Mat  distCoeffs;

    int flag;
    cv::Mat mapx, mapy;
    cv::Mat R = cv::Mat::eye(3,3,CV_32F);
    bool mustInitUndistort;

};

